package demo.reducer;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

public class BaseChainReduce extends MapReduceBase implements Reducer<IntWritable,Text, Text, IntWritable> {

	@Override
	public void reduce(IntWritable arg0, Iterator<Text> arg1, OutputCollector<Text, IntWritable> arg2, Reporter arg3)
			throws IOException {
		// TODO Auto-generated method stub
		StringBuffer sb=new StringBuffer(""); 
		while(arg1.hasNext()){
			sb.append(arg1.next().toString()+":");
		}
		arg2.collect(new Text(sb.toString()), arg0);
	}
	
}
